TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../../config.mk

# Inputs
RMD_FILE := $(TASK_DIR)/src/gen_alternate_spec_outputs.Rmd
BASIC_OLS_FILE := $(TASK_DIR)/../../run_regressions/output/regression_output__basic.csv
BLOCK_FE_FILE := $(TASK_DIR)/../../run_regressions/output/regression_output__main_results_w_blocks_wo_covariates.csv
PAP_FILE := $(TASK_DIR)/../../run_regressions/output/regression_output__main_results_w_just_pap_covariates.csv
DL_I_THREE_COMP_FILE := $(TASK_DIR)/../../run_stata_regressions/output/double_lasso/i_three_components_post_20.xlsx
DL_V_SHOOT_OR_HOM_FILE := $(TASK_DIR)/../../run_stata_regressions/output/double_lasso/v_shooting_or_homicide_post_20.xlsx
DL_A_PARTONE_NON_SHOOT_OR_HOM_FILE := $(TASK_DIR)/../../run_stata_regressions/output/double_lasso/a_partone_non_shooting_or_homicide_post_20.xlsx
DL_A_SHOOT_OR_HOM_FILE := $(TASK_DIR)/../../run_stata_regressions/output/double_lasso/a_shooting_or_homicide_post_20.xlsx
DOUBLE_LASSO_FILE := $(wildcard $(TASK_DIR)/../../run_stata_regressions/output/double_lasso/*.xlsx)
POISSON_FILE := $(TASK_DIR)/../../run_regressions/output/regression_output__main_results_poisson.csv

# One of the outputs
OUT_FILE := $(OUT_DIR)/other_specifications_up_to_date.tex

$(OUT_FILE): $(RMD_FILE) $(BASIC_OLS_FILE) $(BLOCK_FE_FILE) $(DOUBLE_LASSO_FILE) $(PAP_FILE) $(POISSON_FILE) $(OUTCOME_LABELS_FILE) $(TASK_FNS)
	@mkdir -p $(OUT_DIR)
	@mkdir -p $(PAPER_OUT_DIR)
	$(R_script) -e "rmarkdown::render(input = '$(RMD_FILE)')"
	@cp $(OUT_DIR)/*up_to_date.tex $(PAPER_OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_FILE)

clean:
	rm -rf $(OUT_DIR)/*up_to_date*
